package com.example.mouseButtonEvent;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * @Author 郅占伟
 * @ClassName MyMouseEvent
 * @Description TODO
 * @Date 2024年05月10日
 * @Version: 1.0
 */
public class MyMouseEvent implements MouseListener {
    @Override
    public void mouseClicked(MouseEvent e) {
        int button = e.getButton();
        if (e.getButton() == MouseEvent.BUTTON1) {
            System.out.println("鼠标左击");
        }
        if (e.getButton() == MouseEvent.BUTTON3) {
            System.out.println("鼠标右击");
        }
        if (e.getButton() == MouseEvent.BUTTON2) {
            System.out.println("鼠标中键点击");
        }

        System.out.println("鼠标点击" + e.getPoint());
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("鼠标长按,获取的Point是" + e.getPoint());
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("鼠标释放,获取的Point是" + e.getPoint());
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("鼠标mouseEntered,获取的Point是" + e.getPoint());
    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("鼠标退出,获取的Point是" + e.getPoint());
    }
}
